package com.liuya.safe.entitle.service;

import java.util.Collection;
import java.util.Locale;

import com.liuya.base.BaseService;
import com.liuya.common.exception.EntityExistException;
import com.liuya.safe.model.SafePrivilege;

public interface PrivilegeManagerService extends BaseService<SafePrivilege> {

    public SafePrivilege addPrivilege(SafePrivilege pvlg) throws EntityExistException;

    public void updatePrivilege(SafePrivilege pvlg) throws EntityExistException;

    public void deletePrivilege(String id);

    public SafePrivilege getPrivilege(String id);

    public Collection getLikelyPrivileges(String name);

    public Collection getLikelyPrivilegesByUrl(String url);

    public Collection getAllBusinessPrivileges();

    public Collection getAllNonRolePrivileges();

    /**
     * Move privilge to target, and new position is newOrderNum. Nodes before
     * newOrderNum keep their position, while nodes after newOrderNum should
     * move backword(orderNum++)
     *
     * @param privilege
     * @param target
     * @param newOrderNum
     */
    public void movePrivilege(SafePrivilege privilege, SafePrivilege target, int newOrderNum);

    public void deletePrivilegeCascade(String id);

    public SafePrivilege getParent(SafePrivilege privilege);

    public Collection getChildren(SafePrivilege privilege);

    public boolean isChild(String pId, String id);

    public boolean isCascadeChild(String pId, String id);

    public SafePrivilege getBusinessPrivilegeTree();

    public SafePrivilege getNonRolePrivilegeTree();

    public SafePrivilege getTree(String id);

    public void addReservedPrivilege(Locale locale);
}

